const {borrowRemarkModel} = require('../models/bremarkModel')
//新增评论
 function addRemark(req,res) {
    borrowRemarkModel.create(req.body)
   
    res.send({
        msg:'评论添加成功',
        status:1
    })
}
// 查询评论(渲染) 需要将租客或者车主的id关联起来
async function searchRemark(req,res) {
   
   const data =  await borrowRemarkModel.find()
   res.send({
       msg:'查询成功',
       status:1,
       data
   })
}

//修改评论
async function updateRemark(req,res) {
    const {_id,content,score} = req.body
    borrowRemarkModel.updateOne({_id},{content,score})
    res.send({
        msg:'修改成功',
        status:1
    })
}
//删除评论
async function deleteRemark(req,res) {
    const {_id} = req.body
    borrowRemarkModel.deleteOne({_id})
    res.send({
        msg:'删除成功',
        status:1
    })
}
module.exports = {
    addRemark,searchRemark,updateRemark,deleteRemark
}
